package com.yty.eb.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yty.eb.model.EbProduct;
import com.yty.eb.service.EbProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/front")
public class IndexController {
    @Autowired
    private EbProductService ebProductService;

    @RequestMapping("/index")
    public String index(Model model) {
        System.out.println("====进入IndexController的index()方法====");
        //TODO 1.查询商品表的数据 2.查询新闻表的数据 3.查询商品分类表数据
        Page<EbProduct> ebProductPage = ebProductService.page(1, 8);
        //TODO 2.查询新闻表的数据 3.查询商品分类表数据
        //TODO 4.绑定数据到model---数据
        model.addAttribute("ebProductPage", ebProductPage);
        //TODO 5.返回View---index.html
        return "index";//resources/templates/index.html
    }
}
